#ifndef __IDRAWABLESCENENODE_H__
#define __IDRAWABLESCENENODE_H__

#include "ISceneNode.h"

typedef std::vector<IDrawableFace*>	DrawableFaceVectorType;

class IDrawableSceneNode : public ISceneNode
{
protected:
	DrawableFaceVectorType de;
	IBoundingBox BBox;

	virtual void CloneAttributes(ISceneNode *Source)
	{
		ISceneNode::CloneAttributes(Source);
	}

public:
	IDrawableSceneNode(ISceneNodeBasicParamsDeclaration):ISceneNode(ISceneNodeBasicParams)
	{
	}

	virtual ~IDrawableSceneNode()
	{
		DestroyNode();
	}

	virtual void DestroyNode()
	{
		for (u32 i=0;i<de.size();i++)
			delete de[i];

		de.clear();
	}

	inline IBoundingBox *GetBoundingBox()			{	return &BBox;				}

	virtual void SetTexture(u32 Index,ITexture *Texture)
	{
		if (Index < de.size())
		{
			de[Index]->SetTexture(Texture);
		}
	}

	virtual void SetTextures(ITexture *Texture)
	{
		for (u32 i=0;i<de.size();i++)
		{
			de[i]->SetTexture(Texture);
		}
	}

	virtual void UpdateNode()
	{
		for (u32 i=0;i<de.size();i++)
			de[i]->UpdateTransformation(AbsoluteTransformation);
	}

	virtual void Render(IDrawableFaceManager *dfm)	= 0;

	virtual u32 GetNumFaces()
	{
		return de.size();
	}

	virtual IDrawableFace *GetFace(u32 Index)
	{
		return de[Index];
	}

	virtual void SetMaterialAmbients(CColor &Color)
	{
		for (u32 i=0;i<de.size();i++)
		{
			de[i]->SetAmbient(Color);
		}
	}

	virtual void SetMaterialDifuses(CColor &Color)
	{
		for (u32 i=0;i<de.size();i++)
		{
			de[i]->SetDifuse(Color);
		}
	}

	virtual void SetMaterialSpeculars(CColor &Color)
	{
		for (u32 i=0;i<de.size();i++)
		{
			de[i]->SetSpecular(Color);
		}
	}

};

#endif
